<?php 
// Header
$this->set('title_for_layout', __("Chỉnh sửa luận khoa học", true));

$this->left_menu = 'menu/'.$this->params['controller'];
$params = array(
	//'root'	=>	$this->params['named']['root']
);

if (isset($this->params['plugin'])) {
	$params['plugin'] = $this->params['plugin'];
} else {
	$params['plugin'] = null;
}
// -- Load CSS : Begin --
?>
<style>
    .list-table .file {margin-top: 0;}
</style>
<?php
// -- Load CSS : End  --

// Load Javascript
echo $this->Html->script('ckeditor/ckeditor', array('type' => 'text/javascript'));
//echo $this->Html->script('jquery.form');
echo $this->Html->script('/sciences/js/edit');
?>

<script language="javascript">
$(document).ready(function () {
	$('div.buttons a.delete').click(function() {
		if (!confirm("<?php __("Bạn có thật sự muốn xóa luận khoa học này?")?>")) {
			return false;
		}
	});
});

</script>

<h2><?php __("Cập nhật luận khoa học")?></h2>
<?php echo $session->flash()?>

<div class="buttons attop">
	<ul>
		<li><a href="<?php echo $html->url($params + array('plugin' => 'sciences', 'controller' => 'manage_sciences', 'action'	=>	'index'))?>" class="back"><?php __("Danh sách luận khoa học")?></a></li>
		<li><a href="<?php echo $html->url($params + array('plugin' => 'sciences', 'controller' => 'manage_sciences', 'action'=>'delete', $this->data['Science']['id']))?>" class="cancel delete"><?php __("Xóa")?></a></li>
		<li><a href="javascript:void(0)" class="save"><?php __("Cập nhật")?></a></li>
	</ul>
</div>

<?php 
echo $form->create('Science', array(
	'url'	=>	
	$params + array(
		'controller'	=>	$this->params['controller'],	
		'action'		=>	'edit'
	),
	'id'		=>	'edit_page_form',
	'enctype'	=>	'multipart/form-data'
));
?>
<fieldset class="form">
<?php 
echo $form->input('id');
echo $form->input('title', array(
	'label'	=>	__("Tên: ", true),
	'error'	=>	__("Tên không được để trống", true),
	'size'	=> 50
));

if ($configs['Manage']['edit']['show_alias']) {
	echo $form->input('alias', array('label'	=>	__("Alias: ", true)));
} else {
	echo $form->input('alias', array('label'	=>	__("Alias: ", true), 'type' => 'hidden'));
}

if ($configs['Science']['image']['show']):
$options = array(
	'name'				=>	$html->getThumbnailName($this->data['Science']['image']),
	'path'				=>	$configs['Science']['image']['uri'],
	'field_name'		=>	'image',
	'label'				=>	__('&nbsp;',true),
	'legend_title'		=>	__('Hình ảnh',true),
	'delete_image_link'	=>	$html->url($params + array('controller'=>$this->params['controller'], 'action'=>'delete_image'))."/page_id:".$this->data['Science']['id']
);
echo $html->form_image($options,array());
endif;
?>

<?php if ($configs['Science']['description']['show']):?>
<div class="input">
<table cellpadding='0' cellspacing='0' border='0' width='100%' class='list-table'>
<tr>
	<td class='label' valign='top'><label for="description"><?php __("Mô tả: ")?></label></td>
	<td>
		<?php
		echo $form->input('description', array('label'	=>	false, 'div'=>false, 'type'=>'textarea'));
		
		if (!isset($configs['Science']['description']['use_rich_text']) || $configs['Science']['description']['use_rich_text']):
		echo $wysiwyg->render("Science.description", 'ckeditor', $configs['Science']['description_config']);
		endif;
		?>
	</td>
</tr>
</table>
</div>
<?php endif;?>

<?php if ($configs['Science']['content']['show']):?>
<div class="input">
<table cellpadding='0' cellspacing='0' border='0' width='100%' class='list-table'>
<tr>
	<td class='label' valign='top'><label for="description"><?php __("Nội dung: ")?></label></td>
	<td>
		<?php
		echo $form->input('content', array('label'	=>	false, 'div'=>false, 'type'=>'textarea'));
		
		if (!isset($configs['Science']['description']['use_rich_text']) || $configs['Science']['description']['use_rich_text']):
		echo $wysiwyg->render("Science.content", 'ckeditor', $configs['Science']['content_config']);
		endif;
		?>
	</td>
</tr>
</table>
</div>
<?php endif;?>

<?php
echo $form->input('is_published', array('label' => __("Kích hoạt?", true)));
?>
<div style="display:none">
	<input type="submit"/>
</div>
</fieldset>
<?php echo $form->end();?>

<div class="buttons attop">
	<ul>
		<li><a href="<?php echo $html->url($params + array('plugin' => 'Science', 'controller' => 'manage_sciences', 'action'	=>	'index'))?>" class="back"><?php __("Danh sách luận khoa học")?></a></li>
		<li><a href="<?php echo $html->url($params + array('plugin' => 'Science', 'controller' => 'manage_sciences', 'action'=>'delete', $this->data['Science']['id']))?>" class="cancel delete"><?php __("Xóa")?></a></li>
		<li><a href="javascript:void(0)" class="save"><?php __("Cập nhật")?></a></li>
	</ul>
</div>
<?php
if (isset($configs['RelatedImages']) && isset($configs['RelatedImages']['isActive']) && $configs['RelatedImages']['isActive']):
echo $this->element('list_images', array(
'configs'	=>	$configs,
'plugin'	=>	'related_images', 
'settings'=>array(
	'model'		=>	$configs['RelatedImages']['model'],
	'name'		=>	'editable_pages',
	'configFile'	=>	base64_encode($configs['RelatedImages']['configFile'])
),
'related_images'	=>	$this->data['RelatedImage']
));
endif;
?>

<!-- Related Images : Begin -->
<?php 
if (isset($configs['RelatedImages']) && isset($configs['RelatedImages']['isActive']) && $configs['RelatedImages']['isActive']):
echo $this->element('dialogs', array(
'plugin'=>'related_images', 
'settings'=>array(
	'model'	=>	$configs['RelatedImages']['model'],
	'name'	=>	'editable_pages'
)
));
endif;
?>
<?php
if (isset($configs['RelatedImages']) && isset($configs['RelatedImages']['isActive']) && $configs['RelatedImages']['isActive']):
echo $this->Html->script('/related_images/js/ajaxfileupload');
endif;
?>
<!-- Related Images : End -->